package com.zhkj.txg.module.mine.popup

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.view.Gravity
import android.view.View
import android.widget.TextView
import com.zhkj.txg.R
import com.zhkj.txg.utils.ConfigManager
import razerdp.basepopup.BasePopupWindow

class CallPopupWindow(context: Context) : BasePopupWindow(context) {

    init {
        popupGravity = Gravity.CENTER
        setOutSideDismiss(false)
    }

    override fun onCreateContentView(): View = createPopupById(R.layout.popup_receive_confirm)

    override fun onViewCreated(contentView: View?) {
        contentView?.let {
            it.findViewById<TextView>(R.id.tvTitle).text = context.getString(R.string.call)
            it.findViewById<TextView>(R.id.etMemberNickname).text =
                String.format(context.getString(R.string.call_hint), ConfigManager.getCustomerMobile())
            it.findViewById<View>(R.id.tvUserNicknameCancel).setOnClickListener { dismiss() }
            it.findViewById<View>(R.id.tvUserNicknameConfirm).setOnClickListener {
                dismiss()
                val intent = Intent(Intent.ACTION_DIAL)
                intent.data = Uri.parse("tel:${ConfigManager.getCustomerMobile()}")
                context.startActivity(intent)
            }
        }
    }
}